var drawing = document.getElementById('drawing')
if (drawing.getContext) {
  var context = drawing.getContext('2d')
  // 填充文字
  context.fillText('Hello Convas', 100, 100)

  // 导出
  var image = document.createElement('img')
  image.src = drawing.toDataURL('image/png')
  document.body.appendChild(image)
}